<?php
class DelTag extends Action {
	/*
	 * (non-PHPdoc) @see Action::execute()
	 */
	public function execute($params) {
		check_login ( ADMIN_LOGIN_PAGE );
		$data ['success'] = false;
		$tid = irqst ( 'tid' );
		if (empty ( $tid )) {
			$data ['msg'] = '标签编号为空，无法删除';
		} else {
			$tagM = new WebTagModel ();
			$tagM->begin ();
			$rst = $tagM->delete ( $tid );
			if ($rst !== false) {
				$wtM = new WebPageTagModel ();
				$rst = $wtM->delete ( array ('tag_id' => $tid ) );
				if ($rst !== false) {
					$data ['success'] = true;
					$tagM->commit ();
				} else {
					$tagM->rollback ();
					$data ['msg'] = '删除标签出错:' . $wtM->last_error_msg ();
				}
			} else {
				$tagM->rollback ();
				$data ['msg'] = '删除标签出错:' . $tagM->last_error_msg ();
			}
		}
		
		return new JsonView ( $data );
	}
}